<template>
  <div class="taskManageWrapWrap">
    <div v-show="nodataIsshow" class="NodatapageTableInner">
      <div class="nodataCotent"  >
        <i class="iconfont icon-zanwushuju" style="font-size: 120px;"></i>
        <div>当前无正在进行的考核</div>
        <div v-if="$store.state.btnMenuIds.indexOf(93)>-1" style="margin-top: 20px;">
          <addTaskBtn @searchRowsInfo="searchRowsInfo" @getTempalteInfo="getTempalteInfo" :templateList="templateList"></addTaskBtn>
        </div>
      </div>
    </div>
    <div class="taskPageInner" v-show="!nodataIsshow">
      <div class="infoSearchWrap">
        <div style="margin-bottom:12px;font-size: 13px;">
          <span  style="color: #868B97;font-family:MicrosoftYaHei;">考核任务：</span><span style="color:#3975fe;font-family:MicrosoftYaHei;font-weight: bold;">{{examineTask.examineName}}</span>
        </div>
        <div class="infoSearchOne">
          <el-row :gutter="20">
            <el-col :span="24">
              <div class="searchWrap">
                <span class="searchFont">未填报单位：</span>
                <span  v-for="(item,key) in notAgencyTask" :key="key" style="color:#9E9E9E;margin-right: 15px;font-size: 13px; ">{{item.agencyName.replace('政府','')}}</span>
              </div>
            </el-col>
          </el-row>
        </div>
        <div class="infoSearchOne">
          <el-row :gutter="20">
            <el-col :span="24">
              <div class="searchWrap">
                <span class="searchFont">已填报单位：</span>
                <el-radio-group @change="changeInfo(0)" v-model="checkunit" size="mini" style="line-height: 23px;width: 100%;">
                    <el-radio-button v-for="item in readyAgencyTask" :key="item.agencyId"  :label="item.agencyId" >{{item.agencyName.replace('政府','')}}</el-radio-button>
                </el-radio-group>
              </div>
            </el-col>
          </el-row>
        </div>
        <div class="infoSearchOne">
          <el-row :gutter="20">
            <el-col :span="20">
              <div class="searchWrap">
                <el-row :gutter="20">
                  <el-col :span="2">
                    <span class="searchFont" >发布状态：</span>
                  </el-col>
                  <el-col :span="20">
                    <el-radio-group @change="changeInfo(1)" v-model="checkItem" size="mini" >
                      <el-radio-button :label="1">预发布</el-radio-button>
                      <el-radio-button :label="2">反馈意见</el-radio-button>
                      <el-radio-button :label="5">正式发布</el-radio-button>
                    </el-radio-group>
                  </el-col>
                </el-row>
              </div>
            </el-col>
            <div style="float: right;margin-right: 10px;">
              <el-button type="primary" size="mini" @click="$refs.weightBtn.dialogOpen()">考核权重</el-button>
              <span v-show="checkItem==5&&$refs.examinOpinions.rows.length>0">
                <el-button type="primary" style="margin-left: 10px;" v-if="$store.state.btnMenuIds.indexOf(79)>-1" size="mini" @click="$refs.examinOpinions.confirmExamine(1)">确认发布</el-button>
              </span>
            </div>
          </el-row>
        </div>
      </div>
      <div class="pageContent">
        <enterpriseExamine :taskId="this.examineTask.id" ref="enterpriseExamine" @getTempalteInfo="getTempalteInfo" v-show="isUnitsChange" :templateId="examineTask.templateId" :agencyId="checkunit"></enterpriseExamine>
        <examinOpinions ref="examinOpinions" v-show="!isUnitsChange" :examineTask="examineTask" :checkItem="checkItem" @getTempalteInfo="getTempalteInfo"></examinOpinions>
      </div>
    </div>
    <!--dialog-->
    <weightBtn ref="weightBtn" :taskId="this.examineTask.id"></weightBtn>
  </div>
</template>

<script>

  import addTaskBtn from './addTaskBtn.vue';
  import enterpriseExamine from './enterpriseExamine.vue';
  import weightBtn from './weightBtn.vue';
  import examinOpinions from './examinOpinions.vue';

  export default {
    props: [],
    data(){
      return {
        checkunit: "",
        checkItem: "",
        readyAgencyTask: [],
        notAgencyTask: [],
        examineTask: "",
        nounits: ["南山区政府", "大鹏区政府", "坪山区政府", "福田区政府", "光明区政府", "龙岗区政府"],
        doneunits: ["罗湖区政府", "宝安区政府", "市公安局", "市城管局", "盐田区政府"],
        nodataIsshow: false,
        isUnitsChange: true,
        templateList: [],

      }
    },
    components: {addTaskBtn, enterpriseExamine, examinOpinions, weightBtn},
    created(){
      this.getTempalteInfo()
    },
    mounted(){

    },
    methods: {

      searchRowsInfo(){
        this.axios.post(process.env.API_HOST + `/examine/selectTemplateGrid`,{})
          .then(response => {
            const result = response.data
            if (result.code == 200) {
              this.templateList = result.rows
            }
          })
      },
      //获取所有模板信息
      getTempalteInfo(){
        this.axios.post(process.env.API_HOST + `/examine/selectTask`,{})
          .then(response => {
            const result = response.data
            if (result.code == 200&&result.result) {
              this.nodataIsshow = result.result.examineTask.id?false:true
              this.examineTask = result.result.examineTask
              this.notAgencyTask = result.result.notAgencyTask
              this.readyAgencyTask = result.result.readyAgencyTask
              if(this.readyAgencyTask.length>0){
                this.checkunit=this.readyAgencyTask[0].agencyId
              }
              if(this.examineTask.currentStatus==1){//预发布
                this.changeInfo(1)
                this.checkItem=1
              }else if(this.examineTask.currentStatus==4){ //正式发布可以看
                this.changeInfo(1)
                this.checkItem=5
              }
              if(this.notAgencyTask.length>8||this.readyAgencyTask.length>8){
                document.querySelector(".pageContent").style.top='182px'
              }else {
                document.querySelector(".pageContent").style.top='160px'
              }

            }else {
              this.nodataIsshow =true
            }
          })

        this.axios.post(process.env.API_HOST + `/examine/selectTemplateGrid`,{})
          .then(response => {
            const result = response.data
            if (result.code == 200) {
              this.templateList = result.rows
            }
          })
      },
      changeInfo(key){
        if (key) { //状态切换
          this.checkunit = ""
          this.isUnitsChange = false
        } else {
          this.checkItem = ""
          this.isUnitsChange = true
          this.$refs.enterpriseExamine.getExamineInfo()
        }

      },
    },
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import "../../../common/stylus/mixin.styl"
  .taskManageWrapWrap
    page()
    .NodatapageTableInner
      background-color white
      border-radius 5px
      height 100%
      padding 20px
      .nodataCotent
        position: absolute;left: 0;right: 0;top: 0;bottom: 0;margin: auto;height: 200px;width: 200px;color: #3975FE;text-align: center;
    .taskPageInner
      border-radius 5px
      height 100%
      .pageContent
        position absolute
        top 160px
        left 0px
        right 0px
        bottom 0px
        border-radius 5px
        background-color white
      .infoSearchWrap
        padding 20px 20px 3px 20px
        overflow hidden
        margin-bottom 10px
        font-size 14px
        background-color white
        border-radius 5px
        .titleWrap
          text-align: center;color:#3975FE;font-weight: bold;font-size: 22px;margin-bottom: 10px;
        .infoSearchOne
          width 100%
          margin-bottom 8px
          .searchWrap
            white-space nowrap
            overflow hidden
            font-size 14px
            line-height 22px
            width 100%
            .searchFont
              font-size 13px
              color: #868B97;
              font-family:MicrosoftYaHei;
          /*  .el-radio-button
              .el-radio-button__inner
                padding 4px 10px !important
                margin 0 10px;
                border none !important
                color: #9E9E9E;;
            .is-active
              .el-radio-button__inner
                color: #fff;
                background-color: $co1
                border-radius 10px !important*/

</style>
